package com.itheima.config;

import com.itheima.pojo.Apple;
import com.itheima.pojo.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
//配置类
@Configuration
public class UserConfig {

    @Bean
    public Apple apple(){
        return new Apple();
    }
    @Bean
    @Conditional(ClassCondition.class)
    //@ConditionalOnBean
    //@ConditionalOnMissingBean(Apple.class)
    @ConditionalOnProperty(name = "itheima",havingValue ="364")
    public User user(){
        User user = new User();
        user.setName("张三");
        user.setAge(20);
        return user;
    }
}
